var log = function () {
    console.log.apply(console, arguments)
}
//类主要的优势：批量制造object和可封装的方法（内部封装好，外部直接调用）
var Student = function (name, height) {
    this.name = name
    this.height = height
    this.hello = function () {
        log('hello from' + this.name)
    }
}

var s1 = new Student('juran', 180)
log('class, s1', s1.name, s1.height)

s1.name = 'jr'
s1.height = 190
log('class,s1 ', s1.name, s1.height)

var s2 = new Student()
var s3 = new Student()
s2.name = 'juran02'
s3.name = 'juran03'

//不会占用student内存，只会占用prototype的内存
//所以,类只定义属性，prototype定义方法
Student.prototype.greeting = function () {
    console.log(`hello I'm ${this.name} `)
}
//最好不要在prototype内定义属性，造成属性不独立
Student.prototype.update = function (name, age) {
    this.name = name
    this.age = age
}

s1.greeting()
s1.update('juran第二代', 189)
s1.greeting()